﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Mafserver.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="Heritage" %>
<%@ Import Namespace="Heritage.Codebox" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div class="mainname" style="margin-bottom:10px;">
    <div style="float:left;padding-top:12px;"><span class="FreeSetBold" style="padding-left: 30px; padding-bottom: 0px; margin-top:0px; color:#0E1A21; font-size:20px">Список всех ваших игр</span></div>
</div>
    <div class="lowercontent" style="font-size:11px; color: #6B562C !important;">
               <div style="display:table;width:100%;">

   <% 
       bool first = true;
       IList<Games> gam = Utils.GetAllMyGames();
       if (gam.Count == 0)
       {
            %>
            <p>Нет ни одной игры</p>
            <%
       }
       foreach (var game in gam)
       {
           string bg = "#ffffff";
           string shadedtop = "";
           if (first)
           {
               first = false;
               shadedtop = " shadedtop";
           }
           if (game.GameState == Constants.GAME_STATE_AVAILABLE) bg = "#f0fff0";
           if (game.GameState == Constants.GAME_STATE_IN_PROGRESS) bg = "#fff0ff";
           Heritage.GameUserData user = Utils.GetMyGameUserDataInGame(game.GameName);
           %>
           <div style="display:table-row;width:100%;">
           <div class="shaded shadedleft<%=shadedtop %>" style="display:table-cell; background-color:<%=bg%>; font-weight:bold;"><a class="brownlink" href="/Game/View/<%=game.GameName%>"><%=game.GameName%></a></div>
           <div class="shaded<%=shadedtop %>"  style="display:table-cell; background-color:<%=bg%>;"><%=user.UserMask%></div>
           <% if (game.GameState == Constants.GAME_STATE_AVAILABLE)
              { %>
           <div class="shaded<%=shadedtop %>"  style="display:table-cell; background-color:<%=bg%>;">на записи</div>
           <div class="shaded shadedright<%=shadedtop %>"  style="display:table-cell; background-color:<%=bg%>;">&nbsp;</div>
           <% }
              else
              {
                  int state = user.UserState;
                  if (state == Constants.USERSTATE_IN_JAIL) state = Constants.USERSTATE_IMPRISONED;
                  if (state == Constants.USERSTATE_DEAD) state = Constants.USERSTATE_KILLED;
                  string stat = Utils.GetUserStateStringByState(state, user.UserGender);
                  if (user.UserState != Constants.USERSTATE_ALIVE)
                  {
                      stat += " (" + user.OutDate + "-й день)";
                  }
                  stat += " " + Utils.GetSimpleUserRoleString(user.UserRole);
                              %>
            <div class="shaded<%=shadedtop %>"  style="display:table-cell; background-color:<%=bg%>;"><%=stat%></div>
            <% if (game.GameState == Constants.GAME_STATE_FINISHED)
               {
                   string result = string.Format("({0}) {1}", game.GameFinished.Value.ToString("dd.MM.yyyy"), Utils.GetGameResultString(game.GameResult));
            %>
            <div class="shaded shadedright<%=shadedtop %>"  style="display:table-cell; background-color:<%=bg%>;"><%=result%></div>
           <% }
               else
               { %>
                       <div class="shaded shadedright<%=shadedtop %>"  style="display:table-cell; background-color:<%=bg%>;">&nbsp;</div>
            <% 
               }
              }
           %>
           </div>
           <%
       }
   %>
   </div>
   </div>
</asp:Content>
